package cn.edu.cug.cs.gtl.apis.ui.actions;

import cn.edu.cug.cs.gtl.apis.ui.AbstractApplication;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
public class DeviceTreeSelectionListener implements TreeSelectionListener {
    private AbstractApplication theApp=null;

    public DeviceTreeSelectionListener(AbstractApplication theApp) {
        this.theApp = theApp;
    }
    @Override
    public void valueChanged(TreeSelectionEvent e) {
        TreePath treePath = e.getPath();
        DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
        theApp.getMainFrame().getDevicePanel().getTreeComponent().setCurrentSelectedNode(treeNode);
//
//        Object refObject  =  treeNode.getUserObject();
//        if(refObject instanceof String){
//            //Do Nothing
//            String s = (String)refObject;
//        }

    }
}
